package com.example.benefitcommunity.controller;

import com.example.benefitcommunity.entity.BcDynamic;
import com.example.benefitcommunity.entity.BcNotificationAnnouncement;
import com.example.benefitcommunity.entity.Result;
import com.example.benefitcommunity.service.BcDynamicService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 发表动态表(BcDynamic)表控制层
 *
 * @author makejava
 * @since 2025-08-27 16:38:31
 */
@Tag(name = "发表动态")
@CrossOrigin
@RestController
@RequestMapping("bcDynamic")
public class BcDynamicController {
    /**
     * 服务对象
     */
    @Resource
    private BcDynamicService bcDynamicService;

    /**
     * 通过查询数据
     *
     * @param type     类型
     * @param pagenum  页码
     * @param pagesize 页大小
     * @return 数据
     */
    @Operation(description = "发表动态查询")
    @GetMapping("list")
    public Result<Object> queryByDynamic(String type, Integer id, Integer communityid, Integer userid, Integer isshow, Integer pagenum, Integer pagesize) {
        return this.bcDynamicService.queryByDynamic(type, id, communityid, userid, isshow, pagenum, pagesize);
    }

    /**
     * 新增数据
     *
     * @param bcDynamic 实体
     * @return 新增结果
     */
    @Operation(description = "新增发表动态")
    @PostMapping("add")
    public Result<Object> add(@RequestBody BcDynamic bcDynamic) {
        return this.bcDynamicService.insert(bcDynamic);
    }

//    /**
//     * 编辑数据
//     *
//     * @param bcDynamic 实体
//     * @return 编辑结果
//     */
//    @Operation(description = "编辑发表动态")
//    @PutMapping("edit")
//    public Result<Object> edit(@RequestBody BcDynamic bcDynamic) {
//        return this.bcDynamicService.update(bcDynamic);
//    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @Operation(description = "删除发表动态")
    @DeleteMapping("delete")
    public Result<Object> deleteById(Integer[] id) {
        return this.bcDynamicService.deleteById(id);
    }


    /**
     * 编辑数据
     *
     * @param bcDynamic 实体
     * @return 编辑结果
     */
    @Operation(description = "点赞动态")
    @PutMapping("like")
    public Result<Object> like(@RequestBody BcDynamic bcDynamic) {
        return this.bcDynamicService.like(bcDynamic);
    }

}

